<?php
    class User {
        private $ci;        
        
        function __construct() {    
            $this->ci = &get_instance();
        }
        
        function load($id = 0) {
            $user = array();
            if($id == 0) {
                $user_id = $this->ci->system->getUserId();
            } else {
                $user_id = $id;
            }
            if($user_id != 0) {                                
                $user = $this->ci->db->where('id', $user_id)->get('users')->row_array();
                $role_id = $user['role_id'];                                        
            } else {
                $role_id = 1;
            }            
            $user['role'] = $this->ci->db->where('id', $role_id)->get('roles')->row_array();
            return $user;
        }
    } 
?>